package common

import (
	"ginblog/utils/errmsg"
	"github.com/gin-gonic/gin"
)

type LoginBase struct {
	Phone    string
	Email    string
	UserName string
	Password string
}

func (Login *LoginBase) IsSetPhone() bool {
	return Login.Phone != ""
}

func (Login *LoginBase) IsSetEmail() bool {
	return Login.Email != ""
}

func (Login *LoginBase) IsSetUserName() bool {
	return Login.UserName != ""
}

func (Login *LoginBase) IsSetPassword() bool {
	return Login.Password != ""
}

type TokenData struct {
	Token string `json:"token"`
}

// LoginSuccess /** 登陆成功返回
func (Login *LoginBase) LoginSuccess(c *gin.Context, data interface{}) {
	SuccessJson(c, errmsg.SUCCESS, data)
}

// LoginFail /** 登陆失败返回
func (Login *LoginBase) LoginFail(c *gin.Context) {
	SuccessJson(c, errmsg.LOGIN_FAIL, []interface{}{})
}
